package com.df.hotfix.loader;

import javax.tools.SimpleJavaFileObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;

public class OutputFileJavaFileObject extends SimpleJavaFileObject {
    /**
     * Construct a SimpleJavaFileObject of the given kind and with the
     * given URI.
     */
    private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    public OutputFileJavaFileObject(String className) {
        super(URI.create("bytes:///" + className.replace(".", "/") + ".class"), Kind.CLASS);
    }

    @Override
    public OutputStream openOutputStream() throws IOException {
        return outputStream;
    }
}
